import ajax from '../../common/js/ajax'
import router from '@ohos.router'
import data_storage from '@ohos.data.storage';
import featureAbility from '@ohos.ability.featureAbility'
import prompt from '@system.prompt';

export default {
    data: {
        username:false
    },
    onInit() {
        var context = featureAbility.getContext();
        context.getFilesDir().then((filePath) => {
            let storage = data_storage.getStorageSync(filePath + '/myStore')
            this.username = storage.getSync('username', '')
            console.log('测试：' + this.username )
        })
    },
    goLogin(){
        router.push({
            url:'pages/login/login'
        })
    },
    logout(){
        this.$element('dialog').show()
    },
    yes(){
        this.$element('dialog').close()
        var context = featureAbility.getContext();
        context.getFilesDir().then((filePath) => {
            let storage = data_storage.getStorageSync(filePath + '/myStore')
            storage.putSync('username', '')
            storage.flushSync()
        })
        router.push({
            url:'pages/index/index'
        })
    },
    no(){
        this.$element('dialog').close()
    }

}
